

<!--
 * @Description: DSA设备专用检测
 *
 * Copyright (c) 2023 by cgl/微盛信息产业有限公司, All Rights Reserved.
-->
<template>
  <div class="content" style="position: relative;">
    <el-button
			style="position: absolute; top: 0px; right: 10px;"
			type="primary"
			@click="handleAddTestItem03"
		>增加探测器</el-button>

    <div class="innertitle forminput" v-if="tabList.find(item => item.name.indexOf('03') > -1 && item.name.indexOf(':') > -1)">
			<span v-if="itemIndex == 0">（一）</span>
			<span v-if="itemIndex == 1">（二）</span>
			<span v-if="itemIndex == 2">（三）</span>
			<span v-if="itemIndex == 3">（四）</span>
			<span v-if="itemIndex == 4">（五）</span>
			{{ Number(itemIndex) + 1 }}号（位置：<el-input v-model="form.positionName" data-cusValidate="text" style="width: 300px;" @change="handleChangeInfo"/>）
		</div>

    <div class="tip-30">
      统一检测条件：焦点至影像探测器距离 SID =<el-input v-model="form.sid" @change="handleChangeInfo" class="input-line"/>，
      帧率 fps =
      <el-radio-group v-model="form.fpsDisplay" @change="handleChangeInfo">
        <el-radio :label="1">不显示</el-radio>
        <el-radio :label="0">(<el-input v-model="form.fps" @change="handleChangeInfo('fps')" class="input-line"/>)</el-radio>
      </el-radio-group>；
    </div>

    <!-- 1.DSA项目专用检测项目------------------------------------------------------------------------ -->
    <div id="table2-1">
      <div class="innertitle">
        1.DSA项目专用检测项目: (
          <el-checkbox
            v-model="form1.notHave"
            @change="handleChange"
          >该设备无DSA功能，检测无此项</el-checkbox>)
      </div>
      <div>检测用模体：数字减影血管造影质控检测专用体模；影像接收器距焦点最近</div>
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
        <tr>
          <td colspan="3">检测条件</td>
          <td>DSA动态范围</td>
          <td>DSA对比灵敏度</td>
          <td>伪影</td>
        </tr>
        <tr>
          <td style="text-align: left;">
            <!-- <el-radio v-model="form1.condition" :label="1">入射屏直径(cm)</el-radio><br />
            <el-radio v-model="form1.condition" :label="2">长边尺寸(cm)</el-radio> -->
            <el-radio v-model="form1.fov" :label="1">影像增强器视野(mm)</el-radio><br />
            <el-radio v-model="form1.fov" :label="2">平板探测器视野(mm)</el-radio>
          </td>
          <td>管电压(kV)</td>
          <td>
            管电流<br />
            (<el-radio-group v-model="form1.tubeCurrentUnit">
              <el-radio :label="0">mA</el-radio>
              <el-radio :label="1">mAs</el-radio>
            </el-radio-group>)
          </td>
          <td>0.4mm的DSA血管模拟组件可见灰阶</td>
          <td>0.2mmCu 灰阶可见血管模拟组件</td>
          <td>是否存在伪影</td>
        </tr>
        <tr>
          <td>
            <!-- <el-input v-model="form1.dimension" class="input-line"/> -->
            <div v-show="form1.fov == 1">
              <el-input v-model="form1.imageEnhancement"/>
            </div>
            <div v-show="form1.fov == 2">
              <el-input v-model="form1.fov_value1" class="input-line"/> x <el-input v-model="form1.fov_value2" class="input-line"/>
            </div>
          </td>
          <td><el-input v-model="form1.tubeVoltage" class="input-line"/></td>
          <td><el-input v-model="form1.tubeCurrent" class="input-line"/></td>
          <td>
            <div class="flex-column">
              <el-checkbox v-model="form1.grayScale_0_2">0.2mmCu 灰阶</el-checkbox>
              <el-checkbox v-model="form1.grayScale_0_4">0.4mmCu 灰阶</el-checkbox>
              <el-checkbox v-model="form1.grayScale_0_6">0.6mmCu 灰阶</el-checkbox>
              <el-checkbox v-model="form1.grayScale_0_8">0.8mmCu 灰阶</el-checkbox>
              <el-checkbox v-model="form1.grayScale_1_0">1.0mmCu 灰阶</el-checkbox>
              <el-checkbox v-model="form1.grayScale_1_2">1.2mmCu 灰阶</el-checkbox>
              <el-checkbox v-model="form1.grayScale_1_4">1.4mmCu 灰阶</el-checkbox>
            </div>
          </td>
          <td>
            <div class="flex-column">
              <el-checkbox v-model="form1.bloodVessel_0_4">0.4mm 血管模拟组件</el-checkbox>
              <el-checkbox v-model="form1.bloodVessel_0_2" >0.2mm 血管模拟组件</el-checkbox>
              <el-checkbox v-model="form1.bloodVessel_0_1" >0.1mm 血管模拟组件</el-checkbox>
              <el-checkbox v-model="form1.bloodVessel_0_0_5" >0.05mm 血管模拟组件</el-checkbox>
            </div>
          </td>
          <td>
            <el-radio-group v-model="form1.artifact">
              <el-radio :label="true">是</el-radio>
              <el-radio :label="false">否</el-radio>
            </el-radio-group>
          </td>
        </tr>
      </table>
    </div>

    <div id="table9">
      <div class="innertitle">
        其他说明：
      </div>
      <div class="tip-30">
        <el-input
          type="textarea"
          placeholder=""
          v-model="basicForm.specialCircumstances"
          :autosize="{minRows:2}"
          @blur="$bus.$emit('update-basicinfo', basicForm.taskDetectionEquipmentResultId)"
        ></el-input>
      </div>
    </div>
  </div>
</template>

<script>
import {getInfoById03, dsa, saveInfo03, addDetector} from '@/api/testItem/itemDSA03'

export default {
  name: "testItem03",
  data() {
    return {
      itemIndex: 0,
      fovList: [
        {
          id: 1,
          label: 'mm',
          value: '1'
        },
      ],
      readoutList: [
        {
          id: 1,
          label: 'uGy/s',
          value: '1'
        },
        {
          id: 2,
          label: 'uGy/min',
          value: '2'
        },
        {
          id: 3,
          label: 'mGy/min',
          value: '3'
        },
      ],
      fieldSizeList: [
        {
          id: 1,
          label: 'mm',
          value: '1'
        },
      ],
      // tab切换通用数据
			form: {},
			// 表单-1.透视受检者入射体表空气比释动能率典型值
			form1: {

			},
			// 表单-2、透视受检者入射体表空气比释动能率最大值
			form2: {

			},
			itemsId: null,
    };
  },
  props: {
    //
    tabList: {
      type: Array,
      default: () => ([])
    },
		// tab栏
    activeNameEquipment: {
			type: String,
      default: "0",
    },
		// 基本信息数据
    basicForm: {
			type: Object,
      default: () => {
				return {}
			},
    },
		// // 打开录入的行
    // opendialogRow: {
		// 	type: Object,
    //   default: () => {
		// 		return {}
		// 	},
    // },
  },
  // computed: {
  //   basicInfo() {
	// 			return JSON.parse(this.basicForm.basicInfo) || {};
  //   },
  // },
  watch: {
    activeNameEquipment: {
      handler(val) {
		    let _this = this;
				this.$nextTick(()=>{
					// DSA设备专用项目
					// 获取详情
          if (this.activeNameEquipment.indexOf(':') > -1) {
            this.itemIndex = this.activeNameEquipment.split(':')[0].split('-')[1]
          }
          getInfoById03(this.basicForm.resultId, this.itemIndex).then(response => {
            let {itemsId, resultId, sid, fps, fpsDisplay, positionName} = response.data;
            this.itemsId =  response.data?.itemsId;
            this.form = {itemsId, resultId, sid, fps, fpsDisplay, positionName}
            // 1.探测器剂量指示（DDI）
            this.form1 =  response.data?.dsa || {};
          }).catch((response) => {
            console.log("catch-->getInfoById06", response);
            this.$emit("loadingchange", true);
          });
          // 绑定请求
          let itemsLength = 1;
          for (let index = 0; index < itemsLength; index++) {

            let tableInputs = Array.from(document.getElementById(`table2-${index + 1}`).getElementsByTagName("input")).filter(item => {
              return !item.readOnly
            });
            for (let i = 0; i < tableInputs.length; i++) {
							this.bind(tableInputs[i], () => {
								this.submitTestForm(index + 1)
							})
              // let elSelect = this.elHaveComponent(tableInputs[i]) // 获取Component
              // elSelect.$on('change', function(){
              //   _this.validate(tableInputs[i])
              //   _this.submitTestForm(index + 1)
              // })

            }

          }
				})
      },
      deep: true,
      immediate: true
    },
  },
  methods: {

    /**
     * isPostion  table{XX}/table2-{XX}
     */
     handleChangeReadoutValueUnit(value, isPostion) {
      console.log(value, isPostion)
      this.submitTestForm(isPostion)
    },
		// DSA设备专用项目
		submitTestForm(index) {
			console.log("提交检测项", index);
			this.$emit("loadingchange", true); /* 说明绑定成功 */
			this[`form${index}`].itemsId = this.itemsId;
			switch (index) {
				// 1.DAS动态范围。DAS对比灵敏度 伪影
				case 1:
          this.form1.index = Number(this.itemIndex)
					dsa(this.form1).then((response) => {
						// this.$modal.msgSuccess("保存成功");
						response.data ? this.form1 = response.data : "";
						this.$emit("loadingchange", false);
					})
        	break;
			}
		},
		// 更改电压
		changetube(val, index) {
			console.log("更改电压", val);
			if (val == "other") {
				if (index == "5") {
					this.$set(this.form5, "tubeVoltage", "");
				}
				if (index == "7") {
					this.$set(this.form7, "tubeVoltage", "");
				}
				if (index == "81") {
					this.$set(this.form8, "tubeVoltage_1", "");
				}
				if (index == "82") {
					this.$set(this.form8, "tubeVoltage_2", "");
				}
				if (index == "2-8") {
					this.$set(this.form8, "sid", "");
				}
			}
			if (index == "2-1") {
				this.$set(this.form, "cus_formsid", "");
				if(val == "0") {
					this.$set(this.form, "sid", "180");
				}
				if(val == "1") {
					this.$set(this.form, "sid", this.form.cus_formsid);
				}
			}
		},
    handleChangeInfo(field) {
      if (field == 'fps') {
        if (this.form.fps) {
          this.$set(this.form, 'fpsDisplay', 0)
        } else {
          this.$set(this.form, 'fpsDisplay', 1)
        }
      }
      saveInfo03(this.form)
    },
    handleChange() {
      if(this.form1.notHave){
        {
          this.form1.condition = ''
          this.form1.dimensionWidth = ''
          this.form1.dimensionHeight = ''
          this.form1.tubeVoltage = ''
          this.form1.tubeCurrent = ''
          this.form1.grayScale_0_2 = ''
          this.form1.grayScale_0_4 = ''
          this.form1.grayScale_0_6 = ''
          this.form1.grayScale_0_8 = ''
          this.form1.grayScale_1_0 = ''
          this.form1.grayScale_1_2 = ''
          this.form1.grayScale_1_4 = ''
          this.form1.bloodVessel_0_4 = ''
          this.form1.bloodVessel_0_2 = ''
          this.form1.bloodVessel_0_1 = ''
          this.form1.bloodVessel_0_0_5 = ''
          this.form1.artifact = ''
        }
      }
    },
		// 点击增加探测器
		handleAddTestItem03() {
			addDetector(this.basicForm.resultId).then(res => {
				this.$bus.$emit('add-testItem', '03')
			}).catch(err => {})
		}
  },
};
</script>

<style lang="scss" scoped>
@import '../content.scss';
</style>
